package com.bocai.kelalacar.ui.car.set.ada;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bocai.kelalacar.R;
import com.bocai.kelalacar.base.BaseRecyclerAdapter;
import com.bocai.kelalacar.base.BaseRecyclerViewHolder;
import com.bocai.kelalacar.bean.CarDriverBean;
import com.bocai.kelalacar.ui.car.set.act.AddCarActivity;
import com.bocai.kelalacar.ui.car.set.presenter.AddCarPresenter;
import com.bocai.kelalacar.widget.ListBaseAdapter;

import java.util.List;

/**
 * Created by yuanfei on 2017/6/22.
 */

public class CarManageAda extends ListBaseAdapter<CarDriverBean.ContentBean.CarListBean>{

    private AddCarPresenter presenter;

    public CarManageAda(Context context,AddCarPresenter presenter) {
        super(context);
        this.presenter = presenter;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_car_manage;
    }

    @Override
    public void onBindItemHolder(BaseRecyclerViewHolder holder, final int position) {
        LinearLayout llDelete = (LinearLayout) holder.findView(R.id.ll_delete);
        LinearLayout llCar = (LinearLayout) holder.findView(R.id.ll_car);
        TextView tvLicensePlate = (TextView) holder.findView(R.id.tv_license_plate);
        TextView tvCarNum = (TextView) holder.findView(R.id.tv_car_num);

        tvLicensePlate.setText(mDataList.get(position).getCarLicense());
        tvCarNum.setText(mDataList.get(position).getSeats()+"座");

        llCar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mContext.startActivity(new Intent(mContext, AddCarActivity.class).putExtra("data",mDataList.get(position)));

            }
        });
        llDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.deleteCar(mDataList.get(position).getCarId(),position);
            }
        });
    }
}
